<?php
	
	class App extends Object {
		
		/**
		* Outputs a 200 OK status code.
		* @param void
		* @return void
		*/
		private static function _httpStatus200() {
			header("HTTP/1.1 200 OK");
		}
		
		/**
		* Outputs a 301 redirect to the client.
		* @param $url the url to redirect to.
		* @return void
		*/
		private static function _httpStatus301($url) {
			header("HTTP/1.1 301 Moved Permanently");
			header("Location: $url");
		}
		
		/**
		* Outputs a 302 redirect to the client.
		* @param $url - the url to redirect to.
		* @return void
		*/
		private static function _httpStatus302($url) {
			header("HTTP/1.1 302 Found");
			header("Location: $url");
		}
		
		/**
		* Outputs a 404 Not Found status.
		* @param void
		* @return void
		*/
		private static function _httpStatus400() {
			header("HTTP/1.1 400 Bad Request");
		}
		
		/**
		* Outputs a 403 Forbidden status code.
		* @param void
		* @return void
		*/
		private static function _httpStatus403() {
			header("HTTP/1.1 403 Forbidden");
		}
		
		/**
		* Outputs a 404 status code.
		* @param void
		* @return void
		*/
		private static function _httpStatus404() {
			header("HTTP/1.1 404 Not Found");
		}
		
		/*
		* Outputs a 500 Internal server error status code.
		* @param void
		* @return void
		*/
		private static function _httpStatus500() {
			header("HTTP/1.1 500 Internal Server Error");
		}
		
		/**
		* Creates a temporary redirect to the given url.
		* @param (string) $url - url to redirect to.
		* @return void
		*/
		public static function temporaryRedirect($url) {
			header("HTTP/1.1 307 Temporary Redirect");
			header("Location: $url");
		}
		
		/**
		* Creates a temporary redirect to the given url.
		* @param (string) $url - url to redirect to.
		* @return void
		*/
		public static function permanentRedirect($url) {
			self::_httpStatus301($url);
		}
		
		/**
		* Outputs a given status code to the client.
		* @param (int)$code - http status code
		* @param $opts - options if needed.
		* @return void
		*/
		public static function httpStatus($code, $opts = NULL) {
			
			switch(intval($code)) {
				case 200:
					self::_httpStatus200();
				break;
				
				case 301:
					self::_httpStatus301($opts);
				break;
				
				case 302:
					self::_httpStatus302($opts);
				break;
				
				case 400:
					self::_httpStatus400();
				break;
				
				case 403:
					self::_httpStatus403();
				break;
				
				case 404:
					self::_httpStatus404();
				break;
				
				case 500:
					self::_httpStatus500();
				break;
			}
		}
		
		private function __construct() {}
		private function __destruct() {}
		private function __clone() {}
	}
	